package androidx.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.transition.Transition.b;
import java.util.Map;
import o.fx;
import o.nk;
import o.nl;
import o.nm;
import o.nq;
import o.ns;
import o.nu;
import o.nx;
import o.od;
import o.oi;

public class ChangeBounds extends Transition {
    private static final Property<Drawable, PointF> ʻ = new Property<Drawable, PointF>(PointF.class, "boundsOrigin") {
        private Rect ˎ = new Rect();

        public /* synthetic */ Object get(Object obj) {
            return ˎ((Drawable) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ˎ((Drawable) obj, (PointF) obj2);
        }

        public void ˎ(Drawable drawable, PointF pointF) {
            drawable.copyBounds(this.ˎ);
            this.ˎ.offsetTo(Math.round(pointF.x), Math.round(pointF.y));
            drawable.setBounds(this.ˎ);
        }

        public PointF ˎ(Drawable drawable) {
            drawable.copyBounds(this.ˎ);
            return new PointF((float) this.ˎ.left, (float) this.ˎ.top);
        }
    };
    private static nl ʻॱ = new nl();
    private static final Property<View, PointF> ˊॱ = new Property<View, PointF>(PointF.class, "position") {
        public /* synthetic */ Object get(Object obj) {
            return ॱ((View) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ˊ((View) obj, (PointF) obj2);
        }

        public void ˊ(View view, PointF pointF) {
            int round = Math.round(pointF.x);
            int round2 = Math.round(pointF.y);
            oi.ˋ(view, round, round2, view.getWidth() + round, view.getHeight() + round2);
        }

        public PointF ॱ(View view) {
            return null;
        }
    };
    private static final String[] ˋ = new String[]{"android:changeBounds:bounds", "android:changeBounds:clip", "android:changeBounds:parent", "android:changeBounds:windowX", "android:changeBounds:windowY"};
    private static final Property<e, PointF> ˋॱ = new Property<e, PointF>(PointF.class, "bottomRight") {
        public /* synthetic */ Object get(Object obj) {
            return ˏ((e) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ˋ((e) obj, (PointF) obj2);
        }

        public void ˋ(e eVar, PointF pointF) {
            eVar.ˎ(pointF);
        }

        public PointF ˏ(e eVar) {
            return null;
        }
    };
    private static final Property<View, PointF> ˏॱ = new Property<View, PointF>(PointF.class, "bottomRight") {
        public /* synthetic */ Object get(Object obj) {
            return ˎ((View) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ॱ((View) obj, (PointF) obj2);
        }

        public void ॱ(View view, PointF pointF) {
            oi.ˋ(view, view.getLeft(), view.getTop(), Math.round(pointF.x), Math.round(pointF.y));
        }

        public PointF ˎ(View view) {
            return null;
        }
    };
    private static final Property<View, PointF> ॱˊ = new Property<View, PointF>(PointF.class, "topLeft") {
        public /* synthetic */ Object get(Object obj) {
            return ˏ((View) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ॱ((View) obj, (PointF) obj2);
        }

        public void ॱ(View view, PointF pointF) {
            oi.ˋ(view, Math.round(pointF.x), Math.round(pointF.y), view.getRight(), view.getBottom());
        }

        public PointF ˏ(View view) {
            return null;
        }
    };
    private static final Property<e, PointF> ᐝ = new Property<e, PointF>(PointF.class, "topLeft") {
        public /* synthetic */ Object get(Object obj) {
            return ˏ((e) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ˎ((e) obj, (PointF) obj2);
        }

        public void ˎ(e eVar, PointF pointF) {
            eVar.ॱ(pointF);
        }

        public PointF ˏ(e eVar) {
            return null;
        }
    };
    private int[] ͺ;
    private boolean ॱˎ;
    private boolean ᐝॱ;

    static class e {
        private int ʽ;
        private int ˊ;
        private int ˋ;
        private View ˎ;
        private int ˏ;
        private int ॱ;
        private int ॱॱ;

        e(View view) {
            this.ˎ = view;
        }

        void ॱ(PointF pointF) {
            this.ˏ = Math.round(pointF.x);
            this.ॱ = Math.round(pointF.y);
            this.ʽ++;
            if (this.ʽ == this.ॱॱ) {
                ˏ();
            }
        }

        void ˎ(PointF pointF) {
            this.ˋ = Math.round(pointF.x);
            this.ˊ = Math.round(pointF.y);
            this.ॱॱ++;
            if (this.ʽ == this.ॱॱ) {
                ˏ();
            }
        }

        private void ˏ() {
            oi.ˋ(this.ˎ, this.ˏ, this.ॱ, this.ˋ, this.ˊ);
            this.ʽ = 0;
            this.ॱॱ = 0;
        }
    }

    public ChangeBounds() {
        this.ͺ = new int[2];
        this.ॱˎ = false;
        this.ᐝॱ = false;
    }

    public ChangeBounds(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ͺ = new int[2];
        this.ॱˎ = false;
        this.ᐝॱ = false;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ns.ॱ);
        boolean ˏ = fx.ˏ(obtainStyledAttributes, (XmlResourceParser) attributeSet, "resizeClip", 0, false);
        obtainStyledAttributes.recycle();
        ˋ(ˏ);
    }

    @Nullable
    public String[] ˋ() {
        return ˋ;
    }

    public void ˋ(boolean z) {
        this.ॱˎ = z;
    }

    private void ˏ(nx nxVar) {
        View view = nxVar.ॱ;
        if (ViewCompat.ˊᐝ(view) || view.getWidth() != 0 || view.getHeight() != 0) {
            nxVar.ˊ.put("android:changeBounds:bounds", new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
            nxVar.ˊ.put("android:changeBounds:parent", nxVar.ॱ.getParent());
            if (this.ᐝॱ) {
                nxVar.ॱ.getLocationInWindow(this.ͺ);
                nxVar.ˊ.put("android:changeBounds:windowX", Integer.valueOf(this.ͺ[0]));
                nxVar.ˊ.put("android:changeBounds:windowY", Integer.valueOf(this.ͺ[1]));
            }
            if (this.ॱˎ) {
                nxVar.ˊ.put("android:changeBounds:clip", ViewCompat.ˉ(view));
            }
        }
    }

    public void ˋ(@NonNull nx nxVar) {
        ˏ(nxVar);
    }

    public void ॱ(@NonNull nx nxVar) {
        ˏ(nxVar);
    }

    private boolean ˏ(View view, View view2) {
        if (!this.ᐝॱ) {
            return true;
        }
        nx ˎ = ˎ(view, true);
        if (ˎ == null) {
            if (view == view2) {
                return true;
            }
            return false;
        } else if (view2 != ˎ.ॱ) {
            return false;
        } else {
            return true;
        }
    }

    @Nullable
    public Animator ˋ(@NonNull ViewGroup viewGroup, @Nullable nx nxVar, @Nullable nx nxVar2) {
        if (nxVar == null || nxVar2 == null) {
            return null;
        }
        Map map = nxVar.ˊ;
        ViewGroup viewGroup2 = (ViewGroup) map.get("android:changeBounds:parent");
        ViewGroup viewGroup3 = (ViewGroup) nxVar2.ˊ.get("android:changeBounds:parent");
        if (viewGroup2 == null || viewGroup3 == null) {
            return null;
        }
        final View view = nxVar2.ॱ;
        final int i;
        int i2;
        Animator ˋ;
        if (ˏ(viewGroup2, viewGroup3)) {
            Rect rect = (Rect) nxVar.ˊ.get("android:changeBounds:bounds");
            Rect rect2 = (Rect) nxVar2.ˊ.get("android:changeBounds:bounds");
            int i3 = rect.left;
            i = rect2.left;
            int i4 = rect.top;
            final int i5 = rect2.top;
            int i6 = rect.right;
            final int i7 = rect2.right;
            int i8 = rect.bottom;
            final int i9 = rect2.bottom;
            int i10 = i6 - i3;
            int i11 = i8 - i4;
            int i12 = i7 - i;
            int i13 = i9 - i5;
            rect = (Rect) nxVar.ˊ.get("android:changeBounds:clip");
            final Rect rect3 = (Rect) nxVar2.ˊ.get("android:changeBounds:clip");
            i2 = 0;
            if (!((i10 == 0 || i11 == 0) && (i12 == 0 || i13 == 0))) {
                if (!(i3 == i && i4 == i5)) {
                    i2 = 1;
                }
                if (!(i6 == i7 && i8 == i9)) {
                    i2++;
                }
            }
            if (!(rect == null || rect.equals(rect3)) || (rect == null && rect3 != null)) {
                i2++;
            }
            if (i2 > 0) {
                Animator animator;
                if (this.ॱˎ) {
                    Animator animator2;
                    Rect rect4;
                    Object rect5;
                    oi.ˋ(view, i3, i4, Math.max(i10, i12) + i3, Math.max(i11, i13) + i4);
                    if (i3 == i && i4 == i5) {
                        animator2 = null;
                    } else {
                        animator2 = nk.ॱ(view, ˊॱ, ˋॱ().ˏ((float) i3, (float) i4, (float) i, (float) i5));
                    }
                    if (rect == null) {
                        rect4 = new Rect(0, 0, i10, i11);
                    } else {
                        rect4 = rect;
                    }
                    if (rect3 == null) {
                        rect5 = new Rect(0, 0, i12, i13);
                    } else {
                        rect = rect3;
                    }
                    if (rect4.equals(rect5)) {
                        animator = null;
                    } else {
                        ViewCompat.ˎ(view, rect4);
                        Animator ofObject = ObjectAnimator.ofObject(view, "clipBounds", ʻॱ, new Object[]{rect4, rect5});
                        ofObject.addListener(new AnimatorListenerAdapter(this) {
                            private boolean ʻ;
                            final /* synthetic */ ChangeBounds ʽ;

                            public void onAnimationCancel(Animator animator) {
                                this.ʻ = true;
                            }

                            public void onAnimationEnd(Animator animator) {
                                if (!this.ʻ) {
                                    ViewCompat.ˎ(view, rect3);
                                    oi.ˋ(view, i, i5, i7, i9);
                                }
                            }
                        });
                        animator = ofObject;
                    }
                    ˋ = nu.ˋ(animator2, animator);
                } else {
                    oi.ˋ(view, i3, i4, i6, i8);
                    if (i2 == 2) {
                        if (i10 == i12 && i11 == i13) {
                            ˋ = nk.ॱ(view, ˊॱ, ˋॱ().ˏ((float) i3, (float) i4, (float) i, (float) i5));
                        } else {
                            final e eVar = new e(view);
                            ObjectAnimator ॱ = nk.ॱ(eVar, ᐝ, ˋॱ().ˏ((float) i3, (float) i4, (float) i, (float) i5));
                            ObjectAnimator ॱ2 = nk.ॱ(eVar, ˋॱ, ˋॱ().ˏ((float) i6, (float) i8, (float) i7, (float) i9));
                            animator = new AnimatorSet();
                            animator.playTogether(new Animator[]{ॱ, ॱ2});
                            animator.addListener(new AnimatorListenerAdapter(this) {
                                private e mViewBounds = eVar;
                                final /* synthetic */ ChangeBounds ॱ;
                            });
                            ˋ = animator;
                        }
                    } else if (i3 == i && i4 == i5) {
                        ˋ = nk.ॱ(view, ˏॱ, ˋॱ().ˏ((float) i6, (float) i8, (float) i7, (float) i9));
                    } else {
                        ˋ = nk.ॱ(view, ॱˊ, ˋॱ().ˏ((float) i3, (float) i4, (float) i, (float) i5));
                    }
                }
                if (!(view.getParent() instanceof ViewGroup)) {
                    return ˋ;
                }
                viewGroup2 = (ViewGroup) view.getParent();
                od.ˋ(viewGroup2, true);
                ˊ(new nq(this) {
                    boolean ˊ = false;
                    final /* synthetic */ ChangeBounds ॱ;

                    public void ˋ(@NonNull Transition transition) {
                        if (!this.ˊ) {
                            od.ˋ(viewGroup2, false);
                        }
                        transition.ॱ((b) this);
                    }

                    public void ˊ(@NonNull Transition transition) {
                        od.ˋ(viewGroup2, false);
                    }

                    public void ˏ(@NonNull Transition transition) {
                        od.ˋ(viewGroup2, true);
                    }
                });
                return ˋ;
            }
        }
        i2 = ((Integer) nxVar.ˊ.get("android:changeBounds:windowX")).intValue();
        int intValue = ((Integer) nxVar.ˊ.get("android:changeBounds:windowY")).intValue();
        i = ((Integer) nxVar2.ˊ.get("android:changeBounds:windowX")).intValue();
        int intValue2 = ((Integer) nxVar2.ˊ.get("android:changeBounds:windowY")).intValue();
        if (!(i2 == i && intValue == intValue2)) {
            viewGroup.getLocationInWindow(this.ͺ);
            Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
            view.draw(new Canvas(createBitmap));
            final Drawable bitmapDrawable = new BitmapDrawable(createBitmap);
            final float ॱ3 = oi.ॱ(view);
            oi.ˋ(view, 0.0f);
            oi.ˋ(viewGroup).ˊ(bitmapDrawable);
            PropertyValuesHolder ˏ = nm.ˏ(ʻ, ˋॱ().ˏ((float) (i2 - this.ͺ[0]), (float) (intValue - this.ͺ[1]), (float) (i - this.ͺ[0]), (float) (intValue2 - this.ͺ[1])));
            ˋ = ObjectAnimator.ofPropertyValuesHolder(bitmapDrawable, new PropertyValuesHolder[]{ˏ});
            final ViewGroup viewGroup4 = viewGroup;
            final View view2 = view;
            ˋ.addListener(new AnimatorListenerAdapter(this) {
                final /* synthetic */ ChangeBounds ˋ;

                public void onAnimationEnd(Animator animator) {
                    oi.ˋ(viewGroup4).ˎ(bitmapDrawable);
                    oi.ˋ(view2, ॱ3);
                }
            });
            return ˋ;
        }
        return null;
    }
}
